/*
 * To change this template, choose Tools | Templates
 * and open the template in the editor.
 */

package Visitor;

import Arbori.Nod;
import Functii.Constanta;
import Functii.Cos;
import Functii.Ctg;
import Functii.Exp;
import Functii.Log;
import Functii.Necunoscuta;
import Functii.Putere;
import Functii.Radical;
import Functii.Sin;
import Functii.Tg;
import Operatori.Cat;
import Operatori.Minus;
import Operatori.Plus;
import Operatori.Produs;
import XML.TagXML;
/**
 *
 * @author AlinT
 */

public class ToXMLVisitor extends Visitor{
	TagXML current = new TagXML();
	TagXML newTag = new TagXML();

        @Override
	public void visit(Plus p) {
		// TODO Auto-generated method stub
              if (p != null){
                    visit(p.getfStang());
                    TagXML t1=new TagXML(p.getClass().toString());
                    visit(p.getfDrept());
                    TagXML t2=new TagXML(p.getClass().toString());
                    current.setName(p.getClass().toString());
                    current.addTag(t1);
                    current.addTag(t2);
                }

	}

	@Override
	public void visit(Minus m) {
		// TODO Auto-generated method stub
              if (m != null){
                    visit(m.getfStang());
                    TagXML t1=new TagXML(m.getClass().toString());
                    visit(m.getfDrept());
                    TagXML t2=new TagXML(m.getClass().toString());
                    current.setName(m.getClass().toString());
                    current.addTag(t1);
                    current.addTag(t2);
                }

	}

	@Override
	public void visit(Cat m) {
		// TODO Auto-generated method stub
              if (m != null){
                    visit(m.getfStang());
                    TagXML t1=new TagXML(m.getClass().toString());
                    visit(m.getfDrept());
                    TagXML t2=new TagXML(m.getClass().toString());
                    current.setName(m.getClass().toString());
                    current.addTag(t1);
                    current.addTag(t2);
                }

	}

	@Override
	public void visit(Produs p) {
		// TODO Auto-generated method stub
            if (p != null){
                    visit(p.getfStang());
                    TagXML t1=new TagXML(p.getClass().toString());
                    visit(p.getfDrept());
                    TagXML t2=new TagXML(p.getClass().toString());
                    current.setName(p.getClass().toString());
                    current.addTag(t1);
                    current.addTag(t2);
                }
	}

	@Override
	public void visit(Necunoscuta n) {
		// TODO Auto-generated method stub
              if (n != null){
                    visit(n.getfStang());
                    TagXML t1=new TagXML(n.getClass().toString());
                    visit(n.getfDrept());
                    TagXML t2=new TagXML(n.getClass().toString());
                    current.setName(n.getClass().toString());
                    current.addTag(t1);
                    current.addTag(t2);
                }

	}

	@Override
	public void visit(Constanta c) {
		// TODO Auto-generated method stub
              if (c != null){
                    visit(c.getfStang());
                    TagXML t1=new TagXML(c.getClass().toString());
                    visit(c.getfDrept());
                    TagXML t2=new TagXML(c.getClass().toString());
                    current.setName(c.getClass().toString());
                    current.addTag(t1);
                    current.addTag(t2);
                }

	}

	@Override
	public void visit(Sin s) {
		// TODO Auto-generated method stub
              if (s != null){
                    visit(s.getfStang());
                    TagXML t1=new TagXML(s.getClass().toString());
                    visit(s.getfDrept());
                    TagXML t2=new TagXML(s.getClass().toString());
                    current.setName(s.getClass().toString());
                    current.addTag(t1);
                    current.addTag(t2);
                }

	}

	@Override
	public void visit(Cos c) {
		// TODO Auto-generated method stub
              if (c != null){
                    visit(c.getfStang());
                    TagXML t1=new TagXML(c.getClass().toString());
                    visit(c.getfDrept());
                    TagXML t2=new TagXML(c.getClass().toString());
                    current.setName(c.getClass().toString());
                    current.addTag(t1);
                    current.addTag(t2);
                }

	}

	@Override
	public void visit(Tg t) {
		// TODO Auto-generated method stub
              if (t != null){
                    visit(t.getfStang());
                    TagXML t1=new TagXML(t.getClass().toString());
                    visit(t.getfDrept());
                    TagXML t2=new TagXML(t.getClass().toString());
                    current.setName(t.getClass().toString());
                    current.addTag(t1);
                    current.addTag(t2);
                }

	}

	@Override
	public void visit(Ctg c) {
		// TODO Auto-generated method stub
              if (c != null){
                    visit(c.getfStang());
                    TagXML t1=new TagXML(c.getClass().toString());
                    visit(c.getfDrept());
                    TagXML t2=new TagXML(c.getClass().toString());
                    current.setName(c.getClass().toString());
                    current.addTag(t1);
                    current.addTag(t2);
                }

	}

	@Override
	public void visit(Log l) {
		// TODO Auto-generated method stub
              if (l != null){
                    visit(l.getfStang());
                    TagXML t1=new TagXML(l.getClass().toString());
                    visit(l.getfDrept());
                    TagXML t2=new TagXML(l.getClass().toString());
                    current.setName(l.getClass().toString());
                    current.addTag(t1);
                    current.addTag(t2);
                }

	}

	@Override
	public void visit(Exp e) {
              if (e != null){
                    visit(e.getfStang());
                    TagXML t1=new TagXML(e.getClass().toString());
                    visit(e.getfDrept());
                    TagXML t2=new TagXML(e.getClass().toString());
                    current.setName(e.getClass().toString());
                    current.addTag(t1);
                    current.addTag(t2);
                }
		// TODO Auto-generated method stub

	}

	@Override
	public void visit(Radical r) {
		// TODO Auto-generated method stub
              if (r != null){
                    visit(r.getfStang());
                    TagXML t1=new TagXML(r.getClass().toString());
                    visit(r.getfDrept());
                    TagXML t2=new TagXML(r.getClass().toString());
                    current.setName(r.getClass().toString());
                    current.addTag(t1);
                    current.addTag(t2);
                }

	}

	@Override
	public void visit(Nod n) {

                if ( n instanceof Necunoscuta ) this.visit((Necunoscuta)n);
		if ( n instanceof Constanta ) this.visit((Constanta)n);
		if ( n instanceof Plus ) this.visit((Plus)n);
		if ( n instanceof Minus ) this.visit((Minus)n);
		if ( n instanceof Cat ) this.visit((Cat)n);
		if ( n instanceof Produs ) this.visit((Produs)n);
		if ( n instanceof Sin ) this.visit((Sin)n);
		if ( n instanceof Cos ) this.visit((Cos)n);
		if ( n instanceof Tg ) this.visit((Tg)n);
		if ( n instanceof Ctg ) this.visit((Ctg)n);
		if ( n instanceof Radical ) this.visit((Radical)n);
		if ( n instanceof Log ) this.visit((Log)n);
		if ( n instanceof Exp ) this.visit((Exp)n);
                if ( n instanceof Putere) this.visit((Putere)n);
	}

	public final TagXML getCurrent() {
		return current;
	}

	public final void setCurrent(TagXML current) {
		this.current = current;
	}

    @Override
    public void visit(Putere p) {
          if (p != null){
                    visit(p.getfStang());
                    TagXML t1=new TagXML(p.getClass().toString());
                    visit(p.getfDrept());
                    TagXML t2=new TagXML(p.getClass().toString());
                    current.setName(p.getClass().toString());
                    current.addTag(t1);
                    current.addTag(t2);
                }
    }

}
